class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int profit = 0;
        int minn = 1e4 + 1;
        for (auto x:prices){
            profit = max(profit, x - minn);
            minn = min(minn, x);
        }
        return profit;
    }
};